40823152cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • about
  • W1-W4
    • W1
      • leo教學
      • 分組(2人專案)
    • W2
      • 轉軸問題
      • 擊球問題
      • coppeliaSim 比例問題
    • W3
      • 製作簡報
      • 小組網站(共同維護)
    • W4
      • 報告
      • cd2021_2a_age影片排序
      • Ant Renamer 操作說明
  • W5-w9
    • W5
      • stage2-ag12
      • 產品目標
      • 工作分配
    • W6
      • Lua control speed
    • W7
      • keyboard control
      • keyboard control for Four-bar linkage
    • W8
      • Inquire keyboard number
      • basketball Machine 2.4.3
  • stage1-product
    • 版本一
    • 版本二
    • 版本三
    • 版本四
    • pdf
  • Stage2-product
    • 2.1
    • 2.2
    • 2.3
    • 2.4
  • Stage3
    • W10
      • task1
      • task2
    • W11
      • task 1 教學
    • W12
      • stage2-ag12 python keyboard
    • W13
      • gitlab操作
      • xml
    • W14
      • fanuc_m710ic_50_pick_and_place
      • fanuc_m710ic_50_pick_and_place add suction ped
    • W15
      • MTB_robot_pick_and_place
      • MTB_robot_pick_and_place delete GUI
      • Movie subtite
    • W16
      • MTB_robot onshape
      • MTB_robot coppeliasim
      • MTB_robot add suction pad
      • MTB_robot add IK
      • MTB_robot python remote api
      • MTB_robo use require
    • W17
      • basketball machine add Mtb_robot
      • basketball machine final
    • W18
  • github flagged
  • Bug
    • Wsgi.py 打不開
MTB_robot coppeliasim << Previous Next >> MTB_robot add IK

MTB_robot add suction pad

在coppeliaSim裡的MTB_robot增加吸盤控制。(使用老師的程式)

W16_exam.7z

主程式

function sysCall_init()
    -- do some initialization here
     axis1=sim.getObjectHandle('MTB_axis1')
     axis1=sim.getObjectHandle('MTB_axis1')
     axis3=sim.getObjectHandle('MTB_axis3')
     axis4=sim.getObjectHandle('MTB_axis4')
     suctionPad=sim.getObjectHandle('suctionPad')     
     rotation1 = 0
     distance3 = 0
     
     deg = math.pi/180
     --sim.sJointTargetVelocity(joint,5.5)
     
     
    
     

end

function sysCall_actuation()
 calibration = 0.0042
 message,auxiliaryData=sim.getSimulatorMessage()
 if (message==sim.message_keypress) then
      print(auxiliaryData[1])--key
      if (auxiliaryData[1]==string.byte(' ')) then
      end
      if (auxiliaryData[1]==97) then--a
      rotation1 = rotation1 + 5*deg
      sim.setJointPosition(axis1, rotation1)
      end
      if (auxiliaryData[1]==100) then --d
      rotation1 = rotation1 - 5*deg
      sim.setJointPosition(axis1, rotation1)
      end
      if (auxiliaryData[1]==119) then --s
      distance3 = distance3 + 0.01 + calibration
      sim.setJointPosition(axis3, distance3)
      end 
      if (auxiliaryData[1]==115) then --w
      distance3 = distance3 - 0.01 - calibration
      sim.setJointPosition(axis3, distance3)
      end
      if (auxiliaryData[1]==112) then --p activate the suction pad
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','true')
      end -- if p
      if (auxiliaryData[1]==113) then --q deactivate the suction pad
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','false')
      end -- if q
     
 end    


end
function sysCall_sensing()
    -- put your sensing code here
end

function sysCall_cleanup()
    -- do some clean-up here
end

-- See the user manual or the available code snippets for additional callback functions and details

吸盤程式

function sysCall_init() 
    s=sim.getObjectHandle('suctionPadSensor')
    l=sim.getObjectHandle('suctionPadLoopClosureDummy1')
    l2=sim.getObjectHandle('suctionPadLoopClosureDummy2')
    b=sim.getObjectHandle('suctionPad')
    suctionPadLink=sim.getObjectHandle('suctionPadLink')

    infiniteStrength=sim.getScriptSimulationParameter(sim.handle_self,'infiniteStrength')
    maxPullForce=sim.getScriptSimulationParameter(sim.handle_self,'maxPullForce')
    maxShearForce=sim.getScriptSimulationParameter(sim.handle_self,'maxShearForce')
    maxPeelTorque=sim.getScriptSimulationParameter(sim.handle_self,'maxPeelTorque')

    sim.setLinkDummy(l,-1)
    sim.setObjectParent(l,b,true)
    m=sim.getObjectMatrix(l2,-1)
    sim.setObjectMatrix(l,-1,m)
end

function sysCall_cleanup() 
    sim.setLinkDummy(l,-1)
    sim.setObjectParent(l,b,true)
    m=sim.getObjectMatrix(l2,-1)
    sim.setObjectMatrix(l,-1,m)
end 

function sysCall_sensing() 
    parent=sim.getObjectParent(l)
    if (sim.getScriptSimulationParameter(sim.handle_self,'active')==false) then
        if (parent~=b) then
            sim.setLinkDummy(l,-1)
            sim.setObjectParent(l,b,true)
            m=sim.getObjectMatrix(l2,-1)
            sim.setObjectMatrix(l,-1,m)
        end
    else
        if (parent==b) then
            -- Here we want to detect a respondable shape, and then connect to it with a force sensor (via a loop closure dummy dummy link)
            -- However most respondable shapes are set to "non-detectable", so "sim.readProximitySensor" or similar will not work.
            -- But "sim.checkProximitySensor" or similar will work (they don't check the "detectable" flags), but we have to go through all shape objects!
            index=0
            while true do
                shape=sim.getObjects(index,sim.object_shape_type)
                if (shape==-1) then
                    break
                end
                if (shape~=b) and (sim.getObjectInt32Parameter(shape,sim.shapeintparam_respondable)~=0) and (sim.checkProximitySensor(s,shape)==1) then
                    -- Ok, we found a respondable shape that was detected
                    -- We connect to that shape:
                    -- Make sure the two dummies are initially coincident:
                    sim.setObjectParent(l,b,true)
                    m=sim.getObjectMatrix(l2,-1)
                    sim.setObjectMatrix(l,-1,m)
                    -- Do the connection:
                    sim.setObjectParent(l,shape,true)
                    sim.setLinkDummy(l,l2)
                    break
                end
                index=index+1
            end
        else
            -- Here we have an object attached
            if (infiniteStrength==false) then
                -- We might have to conditionally beak it apart!
                result,force,torque=sim.readForceSensor(suctionPadLink) -- Here we read the median value out of 5 values (check the force sensor prop. dialog)
                if (result>0) then
                    breakIt=false
                    if (force[3]>maxPullForce) then breakIt=true end
                    sf=math.sqrt(force[1]*force[1]+force[2]*force[2])
                    if (sf>maxShearForce) then breakIt=true end
                    if (torque[1]>maxPeelTorque) then breakIt=true end
                    if (torque[2]>maxPeelTorque) then breakIt=true end
                    if (breakIt) then
                        -- We break the link:
                        sim.setLinkDummy(l,-1)
                        sim.setObjectParent(l,b,true)
                        m=sim.getObjectMatrix(l2,-1)
                        sim.setObjectMatrix(l,-1,m)
                    end
                end
            end
        end
    end
end 




教學影片:

如何在cippeliasim裡的MTB_robot安裝吸盤。

W16_t.7z


MTB_robot coppeliasim << Previous Next >> MTB_robot add IK

Copyright © All rights reserved | This template is made with by Colorlib